import request from '@/config/axios'
import { TransferReqVO } from '@/api/crm/permission'

/** CRM 产品配件物料信息 */
export interface Components {
          id: number; // 编号，主键自增
          customerId: number; // 所属客户id
          productId: number; // 所属产品id
          componentsName: string; // 物料名称
          componentsNo: string; // 物料代码
          dimension: string; // 物料规格
          componentsUnit: number; // 基本单位
          componentsStatus: number; // 物料状态
          useingStatus: number; // 使用状态
          componentsAttributes: number; // 物料属性
          allPurpose: number; // 配置属性(是否通用)
          componentsLevel: number; // 物料等级
          remark: string; // 备注
  }

// CRM 产品配件物料 API
export const ComponentsApi = {
  // 查询CRM 产品配件物料分页
  getComponentsPage: async (params: any) => {
    return await request.get({ url: `/crm/components/page`, params })
  },

  // 查询CRM 产品配件物料详情
  getComponents: async (id: number) => {
    return await request.get({ url: `/crm/components/get?id=` + id })
  },

  // 新增CRM 产品配件物料
  createComponents: async (data: Components) => {
    return await request.post({ url: `/crm/components/create`, data })
  },

  // 修改CRM 产品配件物料
  updateComponents: async (data: Components) => {
    return await request.put({ url: `/crm/components/update`, data })
  },

  // 删除CRM 产品配件物料
  deleteComponents: async (id: number) => {
    return await request.delete({ url: `/crm/components/delete?id=` + id })
  },

  /** 批量删除CRM 产品配件物料 */
  deleteComponentsList: async (ids: number[]) => {
    return await request.delete({ url: `/crm/components/delete-list?ids=${ids.join(',')}` })
  },

  // 导出CRM 产品配件物料 Excel
  exportComponents: async (params) => {
    return await request.download({ url: `/crm/components/export-excel`, params })
  },
}


// 物料列表
export const getComponentsSimpleList = async (params: any) => {
  return await request.get({ url: `/crm/components/simple-list`, params })
}
